/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lab1;

import java.io.Serializable;
import java.util.Calendar;
import java.util.UUID;

/**
 *
 * @author Александр
 */
public class Task implements Serializable, Comparable<Task> {

    private UUID id;
    private String name;
    private String description;
    private Calendar stime;// начало задачи
    private Calendar ftime;//конец задачи
    private String contacts;
    private Calendar wtime;// время alert
    private Integer freqrep;// частота повтора

    public Task(){
     super();
    }
    
    public Task(Task task){
        this.id = task.id;
        this.contacts = task.contacts;
        this.description = task.description;
        this.freqrep = task.freqrep;
        this.stime = (Calendar) task.stime.clone();
        this.wtime = (Calendar) task.wtime.clone();
        this.ftime = (Calendar) task.ftime.clone();
        this.name = task.name;
    }
    
    public Task(UUID id, String name, String description, Calendar stime, Calendar ftime, String contacts, Calendar wtime, Integer freqrep) {
        this.id = id;
        this.contacts = contacts;
        this.description = description;
        this.freqrep = freqrep;
        this.stime = (Calendar)stime.clone();
        this.wtime = (Calendar)wtime.clone();
        this.ftime = (Calendar)ftime.clone();
        this.name = name;
    }

    public UUID getID() {
        return this.id;
    }

     public void setID(UUID id) {
        this.id=id;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return this.description;
    }

    public void setFtime(Calendar ftime) {
        this.ftime = ftime;
    }

    public Calendar getFtime() {
        return this.ftime;
    }

    public void setWtime(Calendar wtime) {
        this.wtime = wtime;
    }

    public Calendar getWtime() {
        return this.wtime;
    }

    public void setContacts(String contacts) {
        this.contacts = contacts;
    }

    public String getContacts() {
        return this.contacts;
    }

    public void setStime(Calendar stime) {
        this.stime = stime;
    }

    public Calendar getStime() {
        return this.stime;
    }

    public void setFreqrep(Integer freqrep) {
        this.freqrep = freqrep;
    }

    public Integer getFreqrep() {
        return this.freqrep;
    }
    
    @Override
    public String toString(){
        return  "Имя: " + name
                + "   Время выполнения: " + stime.getTime()
                + "  -  " + ftime.getTime()
                + "   Время оповещения " + wtime.getTime();
    }

    @Override
    public int compareTo(Task o) {
        Calendar c1 = this.stime;
        Calendar c2 = o.stime;
        return c1.compareTo(c2);
    }
}
